﻿using System.Drawing;
using System.Windows.Forms;
using System.Xml;

namespace ruscehproj2
{
    public partial class helper : Form
    {
        public int scenarioId;
        string id = "1";
        string hlpString;
        string auxInfoString;
        bool helpActive;
        string shit ="";
        XmlDocument helpdb = new XmlDocument();
        
       

        public void helpEnabled(bool input)
        {
            helpActive = input;
        }

        public bool helpEnabled()
        {
            return helpActive;
        }

        public string getStep()
        {
            return id;
        }

        public void setHelpString(string help)
        {
            hlpString = help;
        }

        public void setHelpId(string _in)
        {
            id = _in;
        }

        public void setAuxInfo(string _in)
        {
            auxInfoString = _in;
        }

        public void notSoFast()
        {
            hlpText.Text = "Не так быстро! Вернитесь назад пожалуйста!";
            auxInfo.Text = "notSoFast";
        }

        public helper()
        {
            InitializeComponent();
        }


        public void hlpRefresh()
        {

            switch (scenarioId)
            { 
                case 0:
                    
            if (!FormManager.shp1.isActive)  id = "1";
                if (FormManager.shp1.is_open)
                {
                    id = "2";
                    if (FormManager.shp1.modeState == 3)
                    {
                        id = "3";
                        if (FormManager.shp1.pwr)
                        {
                            id = "5";
                            if (FormManager.shp1.On1 && FormManager.shp1.On2)
                            { FormManager.shp1.tfRdy.Visible = true; id = "end"; FormManager.shp1.isActive = true; }

                        }
                    }
               }
            
            if (id != "end" && FormManager.shp1.is_open) { FormManager.shp1.tfRdy.Visible = false; FormManager.shp1.isActive = false; } 
            
            if (FormManager.shp1.isActive && !FormManager.shp1.is_open)
            {
                id = "7";
            }
            if (FormManager.bp13.is_open && FormManager.shp1.isActive) id = "8";
            break;
            } 
          
            helpdb.Load("helpdb.xml");
            XmlNodeList nodes = helpdb.GetElementsByTagName("hlpEntry");
            foreach (XmlNode node in nodes)
            {

                if (node.FirstChild.InnerText == id)
                {
                    hlpText.Text = node.FirstChild.NextSibling.InnerText;
                    shit = node.FirstChild.NextSibling.NextSibling.InnerText;
                    auxInfo.Text = id;


                }

                foreach (Control x in ruscehproj2.MAIN.ActiveForm.Controls)
                {
                    if (x is Button)
                    {
                        ((Button)x).FlatAppearance.BorderColor = Color.Black;
                        ((Button)x).FlatAppearance.BorderSize = 0;

                    }
                }



                int size_br = 2;
                Color color_br = Color.Red;
                if (helpActive)
                {
                    switch (id)
                    {
                        case "1": FormManager.MAIN1.shp001.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.shp001.FlatAppearance.BorderColor = color_br;
                            break;
                        case "2": FormManager.shp1.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.shp1.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "3": FormManager.shp1.bigSwitch.FlatAppearance.BorderSize = size_br;
                            FormManager.shp1.bigSwitch.FlatAppearance.BorderColor = color_br;
                            break;
                        case "4": FormManager.MAIN1.bv001dal.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bv001dal.FlatAppearance.BorderColor = color_br;
                            break;
                        case "5": if (!FormManager.shp1.On1)
                            {
                                FormManager.shp1.tfOn1.FlatAppearance.BorderSize = size_br;
                                FormManager.shp1.tfOn1.FlatAppearance.BorderColor = color_br;
                            }
                            if (!FormManager.shp1.On2)
                            {
                                FormManager.shp1.tfOn2.FlatAppearance.BorderSize = size_br;
                                FormManager.shp1.tfOn2.FlatAppearance.BorderColor = color_br;
                            }

                            break;
                        case "6": FormManager.MAIN1.bsh002.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bsh002.FlatAppearance.BorderColor = color_br;
                            break;
                        case "7": FormManager.MAIN1.bp103.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bp103.FlatAppearance.BorderColor = color_br;
                            break;
                        case "8": FormManager.MAIN1.bk007.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bk007.FlatAppearance.BorderColor = color_br;
                            break;
                        case "9": FormManager.MAIN1.bp1161.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bp1161.FlatAppearance.BorderColor = color_br;
                            break;
                        case "10": FormManager.bp61.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.bp61.mode.FlatAppearance.BorderColor = color_br;
                            FormManager.bp62.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.bp62.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "11": FormManager.MAIN1.bp1162.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bp1162.FlatAppearance.BorderColor = color_br;
                            break;
                        case "12": FormManager.bp62.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.bp62.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "13": FormManager.MAIN1.bv009kit1.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bv009kit1.FlatAppearance.BorderColor = color_br;
                            break;
                        case "14": FormManager.bv9kit1.dalOn.FlatAppearance.BorderSize = size_br;
                            FormManager.bv9kit1.dalOn.FlatAppearance.BorderColor = color_br;
                            FormManager.bv9kit1.azOn.FlatAppearance.BorderSize = size_br;
                            FormManager.bv9kit1.azOn.FlatAppearance.BorderColor = color_br;
                            break;
                        case "15": FormManager.bv9kit1.anod1.FlatAppearance.BorderSize = size_br;
                            FormManager.bv9kit1.anod1.FlatAppearance.BorderColor = color_br;
                            FormManager.bv9kit1.anod2.FlatAppearance.BorderSize = size_br;
                            FormManager.bv9kit1.anod2.FlatAppearance.BorderColor = color_br;
                            break;
                        case "16": FormManager.MAIN1.bp1162.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.bp1162.FlatAppearance.BorderColor = color_br;
                            break;
                        case "17": FormManager.bp61.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.bp61.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "18": FormManager.MAIN1.br0041.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.br0041.FlatAppearance.BorderColor = color_br;
                            break;
                        case "19": FormManager.br41.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.vkl.FlatAppearance.BorderColor = color_br;
                            break;
                        case "20": FormManager.br41.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "21": FormManager.br41.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.mode.FlatAppearance.BorderColor = color_br;
                            break;
                        case "22": FormManager.br41.krist1.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.krist1.FlatAppearance.BorderColor = color_br;
                            FormManager.br41.krist2.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.krist2.FlatAppearance.BorderColor = color_br;
                            break;
                        case "23": FormManager.br41.mode.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.mode.FlatAppearance.BorderColor = color_br;
                            FormManager.br41.gain.FlatAppearance.BorderSize = size_br;
                            FormManager.br41.gain.FlatAppearance.BorderColor = color_br;
                            break;
                        case "24": FormManager.MAIN1.br0031.FlatAppearance.BorderSize = size_br;
                            FormManager.MAIN1.br0031.FlatAppearance.BorderColor = color_br;
                            break;
                        case "25": FormManager.br31.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.br31.vkl.FlatAppearance.BorderColor = color_br;
                            break;
                        case "vklCtrl":
                            FormManager.bv1.vklCtrl.FlatAppearance.BorderSize = size_br;
                            FormManager.bv1.vklCtrl.FlatAppearance.BorderColor = color_br;
                            FormManager.bv2dal.vklCtrl.FlatAppearance.BorderSize = size_br;
                            FormManager.bv2dal.vklCtrl.FlatAppearance.BorderColor = color_br;
                            break;
                        case "vkl":
                            FormManager.BSH001.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.BSH001.vkl.FlatAppearance.BorderColor = color_br;
                            FormManager.BSH002.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.BSH002.vkl.FlatAppearance.BorderColor = color_br;
                            FormManager.bsh03.vkl1.FlatAppearance.BorderSize = size_br;
                            FormManager.bsh03.vkl1.FlatAppearance.BorderColor = color_br;
                            FormManager.bsh03.vkl2.FlatAppearance.BorderSize = size_br;
                            FormManager.bsh03.vkl2.FlatAppearance.BorderColor = color_br;
                            FormManager.BK007.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.BK007.vkl.FlatAppearance.BorderColor = color_br;
                            FormManager.br31.vkl.FlatAppearance.BorderSize = size_br;
                            FormManager.br31.vkl.FlatAppearance.BorderColor = color_br;

                            break;
                    }
                }

            }

        }

        
        private void helper_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.F1)
            {
                this.Hide();
                
            }
        }
    }
}
